package com.ttg.common.utils.eazypoi;

import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.ttg.common.utils.DateTimeUtil;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * Description： easypoi导出配置类
 * Author: chenyou
 * Date: 2025/9/27 16:43
 * Company: ttg
 * Copyright: Copyright (c) 2025
 */
@Data
public class ExcelReportConfig {

    private String title;
    private String fileName;
    private String fileType;

    private static final String DEFAULT_FILE_TYPE = ".xlsx";

    public ExcelReportConfig(String title, String fileName) {
        this.title = title;
        this.fileName = fileName;
        this.fileType = DEFAULT_FILE_TYPE;
    }

    public ExcelReportConfig(String title, String fileName, String fileType) {
        this.title = title;
        this.fileName = fileName;
        this.fileType = fileType;
    }

    public String defaultFileNameDateTime(){
        return DateTimeUtil.formatYYYYMMDDHHMMSS(LocalDateTime.now());
    }

    public String defaultTitleDateTime(){
        return DateTimeUtil.formatYYYY_MM_DD_HH_MM_SS(LocalDateTime.now());
    }
    public ExportParams setExportParams(){
        String fileNameDateTime = defaultFileNameDateTime();
        String titleDateTime = defaultTitleDateTime();
        ExportParams exportParams = new ExportParams(getTitle() + titleDateTime, getFileName() + fileNameDateTime);
        exportParams.setCreateHeadRows(true);
        return exportParams;
    }



}
